(defun transform (initial rules)
  (loop for element in initial
	for transformation = (get-transformation rules element)
	appending (result transformation)))

(defun get-transformation (rules element)
  (find element rules :key #'car))

(defun result (transformation)
  (cddr transformation))

(defparameter *fibonnaci-rules* '((a -> b)
				  (b -> a b)))

(defparameter *cantor-rules* '((a -> a b a)
			       (b -> b b b)))

(transform '(a) *fibonnaci-rules*)

(loop for iter upto 20
      for x = '(a) then (transform x *fibonnaci-rules*)
      do (format t "~&~D: ~D~%" iter (length x)))

(loop repeat 3
      for x = '(a) then (transform x *cantor-rules*)
      do (print x))